public class BitComponent32
{
    private uint _state;

    public BitComponent32()
    {
        _state = 0;
    }

    // 设置状态，其中n是状态的数字（1-32）
    public void SetState(uint n)
    {
        if (n >= 1 && n <= 32)
        {
            _state |= 1u << (int)(n - 1);
        }
        else
        {
            throw new ArgumentOutOfRangeException(nameof(n), "State must be between 1 and 32.");
        }
    }

    // 清除状态，其中n是状态的数字（1-32）
    public void ClearState(uint n)
    {
        if (n >= 1 && n <= 32)
        {
            _state &= ~(1u << (int)(n - 1));
        }
        else
        {
            throw new ArgumentOutOfRangeException(nameof(n), "State must be between 1 and 32.");
        }
    }

    // 检查状态是否激活，其中n是状态的数字（1-32）
    public bool IsStateActive(uint n)
    {
        if (n >= 1 && n <= 32)
        {
            return (_state & (1u << (int)(n - 1))) != 0;
        }
        else
        {
            throw new ArgumentOutOfRangeException(nameof(n), "State must be between 1 and 32.");
        }
    }
}
